<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
		<style type="text/css">
			div {
				width: 100vw;
				height: 100vh;
			}
		</style>
	</head>
	<body>
		<div>
			<input id="btn1" type="file" accept="image/*" />
			<button id="button">确定</button>
			<div id="showPic"></div>
		</div>
		<script>
			// id、原名、类型、大小  拍照方向（js   exif库） 
			var formData = new FormData();
			
			var file_ = null;
			
			$('#btn1').on('change', function() {
				file_ = $(this)[0].files[0];
				debugger;
			});
			
			$('#button').on('click', function() {
				
				// 用于确认图片的唯一性，此处建议加上用户的手机号码，以免同一时间多人同时上传图片
				var time = timestamp();
				
				formData.append('file', file_);
				formData.append('token', 'DY8CW0M892Id089Y86WVdFdM6M0MCD9W:Z7vUUzkewO-8YtKgV8HOJ1zNjl0=:eyJzY29wZSI6InJ0cy1wb3J0YWwtZG16LXN0Zy1wcmkiLCJkZWFkbGluZSI6MTUzMzAzNDg2NH0=');
				
				$.ajax({
					url:"http://stg.iobs.pingan.com.cn/upload/rts-portal-dmz-stg-pri/" + time,
					type:"post",
					data: formData,
					processData: false,
					contentType: false,
//					contentType: 'application/json',
					async:true,
					success: function(res) {
						console.log(res);
					},
					error: function(res) {
						console.log(res);
					}
				});
				
			});
			
			function timestamp() {
				var time = new Date();
				
				return time.getTime();
			}
		</script>
	</body>
</html>
